
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class RmsAlertRuleConfigServiceImpl implements RmsAlertRuleConfigService  {

    @Resource
    private RmsAlertRuleConfigMapper rmsAlertRuleConfigMapper;

    /**
     * 获取 RmsAlertRuleConfig 分页列表
     */
    @Transactional
    public IPage getRmsAlertRuleConfigPagination( PaginationVo paginationVo, RmsAlertRuleConfigQuery rmsAlertRuleConfigQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<RmsAlertRuleConfigEntity> lqs = new LambdaQueryWrapper();
        rmsAlertRuleConfigMapper.selectPage(page, lqs);

        List<RmsAlertRuleConfigEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 RmsAlertRuleConfig 所有数据
     *
    */
    @Transactional
    public List<RmsAlertRuleConfigEntity> getRmsAlertRuleConfigAllList( RmsAlertRuleConfigQuery rmsAlertRuleConfigQuery ) throws Exception {

        LambdaQueryWrapper<RmsAlertRuleConfigEntity> lqs = new LambdaQueryWrapper();
        List<RmsAlertRuleConfigEntity> list = rmsAlertRuleConfigMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 RmsAlertRuleConfig 详情
    */
    @Transactional
    public RmsAlertRuleConfigEntity getRmsAlertRuleConfigDetail( Long id) throws Exception {

        RmsAlertRuleConfigEntity rmsAlertRuleConfig = rmsAlertRuleConfigMapper.selectById(id);
        return rmsAlertRuleConfig;
    }


    /**
     * 新增 RmsAlertRuleConfig
     * */
    @Transactional
    public void addRmsAlertRuleConfig(RmsAlertRuleConfigVo rmsAlertRuleConfigVo) throws Exception {

        RmsAlertRuleConfigEntity rmsAlertRuleConfig = new RmsAlertRuleConfigEntity();
        ReflectionCopy.copyProperties( rmsAlertRuleConfig, rmsAlertRuleConfigVo );
        rmsAlertRuleConfigMapper.insert(rmsAlertRuleConfig);
        return;
    }


    /**
     * 更新 RmsAlertRuleConfig
     * */
    @Transactional
    public void updateRmsAlertRuleConfig( RmsAlertRuleConfigVo rmsAlertRuleConfigVo) throws Exception {

        if( rmsAlertRuleConfigVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        RmsAlertRuleConfigEntity rmsAlertRuleConfig = new RmsAlertRuleConfigEntity();
        ReflectionCopy.copyProperties( rmsAlertRuleConfig, rmsAlertRuleConfigVo );
        rmsAlertRuleConfigMapper.updateById(rmsAlertRuleConfig);
        return;
    }

    /**
     * 删除 RmsAlertRuleConfig
     * */
    @Transactional
    public void batchRemoveRmsAlertRuleConfig( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        rmsAlertRuleConfigMapper.deleteBatchIds(ids);
    }

}

      